package architect.design.patterns.structural.composite.simple;

import java.util.ArrayList;
import java.util.List;

/**
 * 经理
 *
 * @author guanxin
 * @date 2018/5/5 14:57
 */

public class Manager implements IEmployee {
    private String name;
    private double salary;
    private List<IEmployee> employees = new ArrayList<IEmployee>();

    public Manager(String name, double salary) {
        this.name = name;
        this.salary = salary;
    }

    public void add(IEmployee employee) {
        employees.add(employee);
    }

    public void remove(IEmployee employee) {
        employees.remove(employee);
    }

    public IEmployee getChild(int i) {
        return employees.get(i);
    }

    public String getName() {
        return this.name;
    }

    public double getSalary() {
        return this.salary;
    }

    public void print() {
        System.out.println("-------------");
        System.out.println("Name =" + getName());
        System.out.println("Salary =" + getSalary());
        System.out.println("-------------");

        for(IEmployee employee : this.employees) {
            employee.print();
        }
    }
}
